package com.iking.toolkit.formatdeal.enums;

import cn.hutool.core.util.ObjectUtil;
import com.iking.toolkit.formatdeal.model.res.SelectOptionRes;
import lombok.Getter;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;


@Getter
public enum FileFormatPathEnum {

    TXT_TO_DOCX("TEXT", new ArrayList<>(Arrays.asList("text", "txt")), "TEXT_TO_DOCX", "/toolkit/text/to_docx", "text转docx"),
    TXT_TO_PDF("TEXT", new ArrayList<>(Arrays.asList("text", "txt")), "TEXT_TO_PDF", "/toolkit/text/to_pdf", "text转pdf"),

    PDF_TO_OFD("PDF", new ArrayList<>(Arrays.asList("pdf")), "PDF_TO_OFD", "/toolkit/pdf/to_ofd", "pdf转ofd"),

    OFD_TO_PDF("OFD", new ArrayList<>(Arrays.asList("ofd")), "OFD_TO_PDF", "/toolkit/ofd/to_pdf", "ofd转pdf"),

    // word转换
    WORD_TO_PDF("WORD", new ArrayList<>(Arrays.asList("doc", "docx")), "WORD_TO_PDF", "/toolkit/word/to_pdf", "word转pdf"),
    // excel转换
    EXCEL_TO_PDF("EXCEL", new ArrayList<>(Arrays.asList("xls", "xlsx")), "EXCEL_TO_PDF", "/toolkit/excel/to_pdf", "excel转pdf"),
    // jpg转换
    JPG_TO_PNG("JPG", new ArrayList<>(Arrays.asList("jpg", "jpeg")), "JPG_TO_PNG", "/toolkit/jpg/to_png", "jpg转png"),
    JPG_TO_BMP("JPG", new ArrayList<>(Arrays.asList("jpg", "jpeg")), "JPG_TO_BMP", "/toolkit/jpg/to_bmp", "jpg转bmp"),
    JPG_TO_GIF("JPG", new ArrayList<>(Arrays.asList("jpg", "jpeg")), "JPG_TO_GIF", "/toolkit/jpg/to_git", "jpg转gif"),
    JPG_TO_PDF("JPG", new ArrayList<>(Arrays.asList("jpg", "jpeg")), "JPG_TO_PDF", "/toolkit/jpg/to_pdf", "jpg转pdf"),
    // png转换
    PNG_TO_JPG("PNG", new ArrayList<>(Arrays.asList("png")), "PNG_TO_JPG", "/toolkit/png/to_jpg", "png转jpg"),
    PNG_TO_BMP("PNG", new ArrayList<>(Arrays.asList("png")), "PNG_TO_BMP", "/toolkit/png/to_bmp", "png转bmp"),
    PNG_TO_GIF("PNG", new ArrayList<>(Arrays.asList("png")), "PNG_TO_GIF", "/toolkit/png/to_gif", "png转gif"),
    PNG_TO_PDF("PNG", new ArrayList<>(Arrays.asList("png")), "PNG_TO_PDF", "/toolkit/png/to_pdf", "png转pdf"),
    // gif转换
    GIF_TO_PDF("GIF", new ArrayList<>(Arrays.asList("gif")), "GIF_TO_PDF", "/toolkit/gif/to_pdf", "gif转pdf"),
    GIF_TO_PNG("GIF", new ArrayList<>(Arrays.asList("gif")), "GIF_TO_PNG", "/toolkit/gif/to_png", "gif转png"),
    GIF_TO_JPG("GIF", new ArrayList<>(Arrays.asList("gif")), "GIF_TO_JPG", "/toolkit/gif/to_jpg", "gif转jpg"),
    GIF_TO_BMP("GIF", new ArrayList<>(Arrays.asList("gif")), "GIF_TO_BMP", "/toolkit/gif/to_bmp", "gif转bmp"),
    // bmp转换
    BMP_TO_PNG("BMP", new ArrayList<>(Arrays.asList("bmp")), "BMP_TO_PNG", "/toolkit/bmp/to_png", "bmp转png"),
    BMP_TO_JPG("BMP", new ArrayList<>(Arrays.asList("bmp")), "BMP_TO_JPG", "/toolkit/bmp/to_jpg", "bmp转jpg"),
    BMP_TO_GIF("BMP", new ArrayList<>(Arrays.asList("bmp")), "BMP_TO_GIF", "/toolkit/bmp/to_gif", "bmp转gif"),
    BMP_TO_PDF("BMP", new ArrayList<>(Arrays.asList("bmp")), "BMP_TO_PDF", "/toolkit/bmp/to_pdf", "bmp转pdf"),
    // mp4转换
    MP4_TO_FLV("MP4", new ArrayList<>(Arrays.asList("mp4")), "MP4_TO_FLV", "/toolkit/mp4/to_flv", "mp4转flv"),
    MP4_TO_AVI("MP4", new ArrayList<>(Arrays.asList("mp4")), "MP4_TO_AVI", "/toolkit/mp4/to_avi", "mp4转avi"),
    MP4_TO_MOV("MP4", new ArrayList<>(Arrays.asList("mp4")), "MP4_TO_MOV", "/toolkit/mp4/to_mov", "mp4转mov"),
    MP4_TO_MKV("MP4", new ArrayList<>(Arrays.asList("mp4")), "MP4_TO_MKV", "/toolkit/mp4/to_mkv", "mp4转mkv"),
    MP4_TO_WMV("MP4", new ArrayList<>(Arrays.asList("mp4")), "MP4_TO_WMV", "/toolkit/mp4/to_wmv", "mp4转wmv"),
    MP4_TO_WEBM("MP4", new ArrayList<>(Arrays.asList("mp4")), "MP4_TO_WEBM", "/toolkit/mp4/to_webm", "mp4转webm"),
    MP4_TO_3GP("MP4", new ArrayList<>(Arrays.asList("mp4")), "MP4_TO_3GP", "/toolkit/mp4/to_3gp", "mp4转3gp"),
    MP4_TO_MPEG_2("MP4", new ArrayList<>(Arrays.asList("mp4")), "MP4_TO_MPEG_2", "/toolkit/mp4/to_mpeg", "mp4转mpeg"),
    // flv转换
    FLV_TO_MP4("FLV", new ArrayList<>(Arrays.asList("flv")), "FLV_TO_MP4", "/toolkit/flv/to_mp4", "flv转mp4"),
    FLV_TO_AVI("FLV", new ArrayList<>(Arrays.asList("flv")), "FLV_TO_AVI", "/toolkit/flv/to_avi", "flv转avi"),
    FLV_TO_MOV("FLV", new ArrayList<>(Arrays.asList("flv")), "FLV_TO_MOV", "/toolkit/flv/to_mov", "flv转mov"),
    FLV_TO_MKV("FLV", new ArrayList<>(Arrays.asList("flv")), "FLV_TO_MKV", "/toolkit/flv/to_mkv", "flv转mkv"),
    FLV_TO_WMV("FLV", new ArrayList<>(Arrays.asList("flv")), "FLV_TO_WMV", "/toolkit/flv/to_wmv", "flv转wmv"),
    FLV_TO_WEBM("FLV", new ArrayList<>(Arrays.asList("flv")), "FLV_TO_WEBM", "/toolkit/flv/to_webm", "flv转webm"),
    FLV_TO_3GP("FLV", new ArrayList<>(Arrays.asList("flv")), "FLV_TO_3GP", "/toolkit/flv/to_3gp", "flv转3gp"),
    FLV_TO_MPEG_2("FLV", new ArrayList<>(Arrays.asList("flv")), "FLV_TO_MPEG_2", "/toolkit/flv/to_mpeg_2", "flv转mpeg_2"),
    // avi转换
    AVI_TO_MP4("AVI", new ArrayList<>(Arrays.asList("avi")), "AVI_TO_MP4", "/toolkit/avi/to_mp4", "avi转mp4"),
    AVI_TO_FLV("AVI", new ArrayList<>(Arrays.asList("avi")), "AVI_TO_FLV", "/toolkit/avi/to_flv", "avi转flv"),
    AVI_TO_MOV("AVI", new ArrayList<>(Arrays.asList("avi")), "AVI_TO_MOV", "/toolkit/avi/to_mov", "avi转mov"),
    AVI_TO_MKV("AVI", new ArrayList<>(Arrays.asList("avi")), "AVI_TO_MKV", "/toolkit/avi/to_mkv", "avi转mkv"),
    AVI_TO_WMV("AVI", new ArrayList<>(Arrays.asList("avi")), "AVI_TO_WMV", "/toolkit/avi/to_wmv", "avi转wmv"),
    AVI_TO_WEBM("AVI", new ArrayList<>(Arrays.asList("avi")), "AVI_TO_WEBM", "/toolkit/avi/to_webm", "avi转webm"),
    AVI_TO_3GP("AVI", new ArrayList<>(Arrays.asList("avi")), "AVI_TO_3GP", "/toolkit/avi/to_3gp", "avi转3gp"),
    AVI_TO_MPEG_2("AVI", new ArrayList<>(Arrays.asList("avi")), "AVI_TO_MPEG_2", "/toolkit/avi/to_mpeg_2", "avi转mpeg_2"),
    // mov转换
    MOV_TO_MP4("MOV", new ArrayList<>(Arrays.asList("mov")), "MOV_TO_MP4", "/toolkit/mov/to_mp4", "mov转mp4"),
    MOV_TO_FLV("MOV", new ArrayList<>(Arrays.asList("mov")), "MOV_TO_FLV", "/toolkit/mov/to_flv", "mov转flv"),
    MOV_TO_AVI("MOV", new ArrayList<>(Arrays.asList("mov")), "MOV_TO_AVI", "/toolkit/mov/to_avi", "mov转avi"),
    MOV_TO_MKV("MOV", new ArrayList<>(Arrays.asList("mov")), "MOV_TO_MKV", "/toolkit/mov/to_mkv", "mov转mkv"),
    MOV_TO_WMV("MOV", new ArrayList<>(Arrays.asList("mov")), "MOV_TO_WMV", "/toolkit/mov/to_wmv", "mov转wmv"),
    MOV_TO_WEBM("MOV", new ArrayList<>(Arrays.asList("mov")), "MOV_TO_WEBM", "/toolkit/mov/to_webm", "mov转webm"),
    MOV_TO_3GP("MOV", new ArrayList<>(Arrays.asList("mov")), "MOV_TO_3GP", "/toolkit/mov/to_3gp", "mov转3gp"),
    MOV_TO_MPEG_2("MOV", new ArrayList<>(Arrays.asList("mov")), "MOV_TO_MPEG_2", "/toolkit/mov/to_mpeg_2", "mov转mpeg_2"),
    // mkv转换
    MKV_TO_MP4("MKV", new ArrayList<>(Arrays.asList("mkv")), "MKV_TO_MP4", "/toolkit/mkv/to_mp4", "mkv转mp4"),
    MKV_TO_FLV("MKV", new ArrayList<>(Arrays.asList("mkv")), "MKV_TO_FLV", "/toolkit/mkv/to_flv", "mkv转flv"),
    MKV_TO_AVI("MKV", new ArrayList<>(Arrays.asList("mkv")), "MKV_TO_AVI", "/toolkit/mkv/to_avi", "mkv转avi"),
    MKV_TO_MOV("MKV", new ArrayList<>(Arrays.asList("mkv")), "MKV_TO_MOV", "/toolkit/mkv/to_mov", "mkv转mov"),
    MKV_TO_WMV("MKV", new ArrayList<>(Arrays.asList("mkv")), "MKV_TO_WMV", "/toolkit/mkv/to_wmv", "mkv转wmv"),
    MKV_TO_WEBM("MKV", new ArrayList<>(Arrays.asList("mkv")), "MKV_TO_WEBM", "/toolkit/mkv/to_webm", "mkv转webm"),
    MKV_TO_3GP("MKV", new ArrayList<>(Arrays.asList("mkv")), "MKV_TO_3GP", "/toolkit/mkv/to_3gp", "mkv转3gp"),
    MKV_TO_MPEG_2("MKV", new ArrayList<>(Arrays.asList("mkv")), "MKV_TO_MPEG_2", "/toolkit/mkv/to_mpeg_2", "mkv转mpeg_2"),
    // wmv转换
    WMV_TO_MP4("WMV", new ArrayList<>(Arrays.asList("wmv")), "WMV_TO_MP4", "/toolkit/wmv/to_mp4", "wmv转mp4"),
    WMV_TO_FLV("WMV", new ArrayList<>(Arrays.asList("wmv")), "WMV_TO_FLV", "/toolkit/wmv/to_flv", "wmv转flv"),
    WMV_TO_AVI("WMV", new ArrayList<>(Arrays.asList("wmv")), "WMV_TO_AVI", "/toolkit/wmv/to_avi", "wmv转avi"),
    WMV_TO_MOV("WMV", new ArrayList<>(Arrays.asList("wmv")), "WMV_TO_MOV", "/toolkit/wmv/to_mov", "wmv转mov"),
    WMV_TO_MKV("WMV", new ArrayList<>(Arrays.asList("wmv")), "WMV_TO_MKV", "/toolkit/wmv/to_mkv", "wmv转mkv"),
    WMV_TO_WEBM("WMV", new ArrayList<>(Arrays.asList("wmv")), "WMV_TO_WEBM", "/toolkit/wmv/to_webm", "wmv转webm"),
    WMV_TO_3GP("WMV", new ArrayList<>(Arrays.asList("wmv")), "WMV_TO_3GP", "/toolkit/wmv/to_3gp", "wmv转3gp"),
    WMV_TO_MPEG_2("WMV", new ArrayList<>(Arrays.asList("wmv")), "WMV_TO_MPEG_2", "/toolkit/wmv/to_mpeg_2", "wmv转mpeg2"),
    // webg转换
    WEBM_TO_MP4("WEBM", new ArrayList<>(Arrays.asList("webm")), "WEBM_TO_MP4", "/toolkit/webm/to_mp4", "webm转mp4"),
    WEBM_TO_FLV("WEBM", new ArrayList<>(Arrays.asList("webm")), "WEBM_TO_FLV", "/toolkit/webm/to_flv", "webm转flv"),
    WEBM_TO_AVI("WEBM", new ArrayList<>(Arrays.asList("webm")), "WEBM_TO_AVI", "/toolkit/webm/to_avi", "webm转avi"),
    WEBM_TO_MOV("WEBM", new ArrayList<>(Arrays.asList("webm")), "WEBM_TO_MOV", "/toolkit/webm/to_mov", "webm转mov"),
    WEBM_TO_MKV("WEBM", new ArrayList<>(Arrays.asList("webm")), "WEBM_TO_MKV", "/toolkit/webm/to_mkv", "webm转mkv"),
    WEBM_TO_WMV("WEBM", new ArrayList<>(Arrays.asList("webm")), "WEBM_TO_WMV", "/toolkit/webm/to_wmv", "webm转wmv"),
    WEBM_TO_3GP("WEBM", new ArrayList<>(Arrays.asList("webm")), "WEBM_TO_3GP", "/toolkit/webm/to_3gp", "webm转3gp"),
    WEBM_TO_MPEG_2("WEBM", new ArrayList<>(Arrays.asList("webm")), "WEBM_TO_MPEG_2", "/toolkit/webm/to_mpeg_2", "webm转mpeg_2"),
    // 3gp转换
    VIDEO_3GP_TO_MP4("3GP", new ArrayList<>(Arrays.asList("3gp")), "VIDEO_3GP_TO_MP4", "/toolkit/3gp/to_mp4", "3gp转mp4"),
    VIDEO_3GP_TO_FLV("3GP", new ArrayList<>(Arrays.asList("3gp")), "VIDEO_3GP_TO_FLV", "/toolkit/3gp/to_flv", "3gp转flv"),
    VIDEO_3GP_TO_AVI("3GP", new ArrayList<>(Arrays.asList("3gp")), "VIDEO_3GP_TO_AVI", "/toolkit/3gp/to_avi", "3gp转avi"),
    VIDEO_3GP_TO_MOV("3GP", new ArrayList<>(Arrays.asList("3gp")), "VIDEO_3GP_TO_MOV", "/toolkit/3gp/to_mov", "3gp转mov"),
    VIDEO_3GP_TO_MKV("3GP", new ArrayList<>(Arrays.asList("3gp")), "VIDEO_3GP_TO_MKV", "/toolkit/3gp/to_mkv", "3gp转mkv"),
    VIDEO_3GP_TO_WMV("3GP", new ArrayList<>(Arrays.asList("3gp")), "VIDEO_3GP_TO_WMV", "/toolkit/3gp/to_wmv", "3gp转wmv"),
    VIDEO_3GP_TO_WEBP("3GP", new ArrayList<>(Arrays.asList("3gp")), "VIDEO_3GP_TO_WEBP", "/toolkit/3gp/to_webp", "3gp转webp"),
    VIDEO_3GP_TO_MPEG_2("3GP", new ArrayList<>(Arrays.asList("3gp")), "VIDEO_3GP_TO_MPEG_2", "/toolkit/3gp/to_mpeg_2", "3gp转mpeg_2"),
    // mpeg 转换
    MPEG2_TO_MP4("MPEG", new ArrayList<>(Arrays.asList("mpg", "mpeg")), "MPEG2_TO_MP4", "/toolkit/mpeg/to_mp4", "mpeg转mp4"),
    MPEG2_TO_FLV("MPEG", new ArrayList<>(Arrays.asList("mpg", "mpeg")), "MPEG2_TO_FLV", "/toolkit/mpeg/to_flv", "mpeg转flv"),
    MPEG2_TO_AVI("MPEG", new ArrayList<>(Arrays.asList("mpg", "mpeg")), "MPEG2_TO_AVI", "/toolkit/mpeg/to_avi", "mpeg转avi"),
    MPEG2_TO_MOV("MPEG", new ArrayList<>(Arrays.asList("mpg", "mpeg")), "MPEG2_TO_MOV", "/toolkit/mpeg/to_mov", "mpeg转mov"),
    MPEG2_TO_MKV("MPEG", new ArrayList<>(Arrays.asList("mpg", "mpeg")), "MPEG2_TO_MKV", "/toolkit/mpeg/to_mkv", "mpeg转mkv"),
    MPEG2_TO_WMV("MPEG", new ArrayList<>(Arrays.asList("mpg", "mpeg")), "MPEG2_TO_WMV", "/toolkit/mpeg/to_wmv", "mpeg转wmv"),
    MPEG2_TO_WEBP("MPEG", new ArrayList<>(Arrays.asList("mpg", "mpeg")), "MPEG2_TO_WEBP", "/toolkit/mpeg/to_webp", "mpeg转webp"),
    MPEG2_TO_3GP("MPEG", new ArrayList<>(Arrays.asList("mpg", "mpeg")), "MPEG2_TO_3GP", "/toolkit/mpeg/to_3gp", "mpeg转3gp"),
    ;
    /**
     * 转换文件类型
     */
    private final String type;

    /**
     * 文件后缀
     */
    private List<String> fileSuffix;
    /**
     * 转换动作
     */
    private final String action;
    /**
     * 存储路径
     */
    private final String path;

    /**
     * 名称
     */
    private final String name;

    FileFormatPathEnum(String type, List<String> fileSuffix, String action, String path, String name) {
        this.type = type;
        this.fileSuffix = fileSuffix;
        this.action = action;
        this.path = path;
        this.name = name;
    }

    /**
     * 根据action获取对应枚举
     *
     * @param action
     * @return
     */
    public static FileFormatPathEnum getByAction(String action) {
        return Arrays.stream(values())
                .filter(e -> ObjectUtil.equal(action, e.getAction())).findFirst().orElse(null);
    }

    /**
     * 获取所有action
     *
     * @return
     */
    public static List<String> getActionList() {
        return Arrays.stream(FileFormatPathEnum.values()).map(FileFormatPathEnum::getAction)
                .collect(Collectors.toList());
    }

    /**
     * 将枚举转List
     *
     * @return
     */
    public static List<SelectOptionRes> getEnumList() {
        List<SelectOptionRes> list = new ArrayList<>();
        for (FileFormatPathEnum item : FileFormatPathEnum.values()) {
            list.add(new SelectOptionRes(item.getAction(), item.getName()));
        }
        return list;
    }

}
